package com.mdx.rest.repository;

import com.mdx.api.entity.CommunityRole;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author : jiagang
 * @date : Created in 2022/2/9 14:52
 */
@Repository
public interface RoleRepository extends JpaRepository<CommunityRole,Long> {

    @Query(value = "SELECT r.role_id as roleId ,r.role_code as roleCode FROM mdx_user_role mr left join mdx_role r on  mr.role_id=r.role_id WHERE mr.user_id=?1",nativeQuery = true)
    List<CommunityRole> findRoleAllByUserId(Long userId);
}
